'use strict';

const Controller = require('egg').Controller;

class VipController extends Controller {
  async vipPost() {
    const { ctx, service } = this;
    let arr = await service.add.addVip(ctx.request.body);
    this.ctx.body = arr;
  }

  async vipGet() {
    const { ctx, service } = this;
    let { findObj, pageObj } = ctx.request.body;
    let arr;
    if (!findObj.roleClass || findObj.roleClass == -1) {
      // 模糊查询
      arr = await service.get.getVip({ tell: { $regex: findObj.tell } }, pageObj);
    } else {
      arr = await service.get.getVip({ tell: { $regex: findObj.tell }, roleClass: findObj.roleClass }, pageObj);
    }

    this.ctx.body = arr;
  }

  /**
   *充值
   *
   * @memberof VipController
   */
  async vipTapUp() {
    const { ctx, service } = this;
    let reqObj = ctx.request.body;
    let obj = await service.add.addvipTapUp(reqObj);
    this.ctx.body = obj;
  }

}

module.exports = VipController;
